<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="数据网关管理平台 - 统一数据接入和API管理" />
    <meta name="keywords" content="数据网关,API管理,数据源,监控,插件" />
    <meta name="author" content="Data Gateway Team" />
    
    <!-- 预加载关键资源 -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    
    <!-- 字体 -->
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
    
    <!-- 主题色彩 -->
    <meta name="theme-color" content="#000000" />
    <meta name="msapplication-TileColor" content="#000000" />
    
    <!-- PWA相关 -->
    <link rel="manifest" href="/manifest.json" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="default" />
    <meta name="apple-mobile-web-app-title" content="数据网关" />
    
    <!-- Open Graph -->
    <meta property="og:type" content="website" />
    <meta property="og:title" content="数据网关管理平台" />
    <meta property="og:description" content="统一数据接入和API管理平台" />
    <meta property="og:image" content="/og-image.png" />
    
    <!-- Twitter Card -->
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:title" content="数据网关管理平台" />
    <meta name="twitter:description" content="统一数据接入和API管理平台" />
    <meta name="twitter:image" content="/twitter-image.png" />
    
    <title>数据网关管理平台</title>
    
    <style>
      /* 加载动画样式 */
      .loading-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
      }
      
      .loading-spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #3b82f6;
        border-radius: 50%;
        animation: spin 1s linear infinite;
      }
      
      @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
      }
      
      .loading-text {
        margin-top: 16px;
        color: #6b7280;
        font-size: 14px;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
      }
      
      /* 暗色主题支持 */
      @media (prefers-color-scheme: dark) {
        .loading-container {
          background: #0f172a;
        }
        .loading-text {
          color: #94a3b8;
        }
      }
      
      /* 隐藏加载动画 */
      .loading-hidden {
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
      }
    </style>
  </head>
  <body>
    <!-- 应用根节点 -->
    <div id="root"></div>
    
    <!-- 初始加载动画 -->
    <div id="loading" class="loading-container">
      <div>
        <div class="loading-spinner"></div>
        <div class="loading-text">正在加载数据网关管理平台...</div>
      </div>
    </div>
    
    <!-- 不支持JavaScript的提示 -->
    <noscript>
      <div style="
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
        color: #374151;
        text-align: center;
        padding: 20px;
        box-sizing: border-box;
      ">
        <div>
          <h1 style="font-size: 24px; margin-bottom: 16px;">需要启用JavaScript</h1>
          <p style="font-size: 16px; line-height: 1.5;">
            数据网关管理平台需要JavaScript才能正常运行。<br>
            请在浏览器设置中启用JavaScript，然后刷新页面。
          </p>
        </div>
      </div>
    </noscript>
    
    <!-- 应用脚本 -->
    <script type="module" src="/src/main.tsx"></script>
    
    <!-- 隐藏加载动画的脚本 -->
    <script>
      // 当页面加载完成后隐藏加载动画
      window.addEventListener('load', function() {
        setTimeout(function() {
          const loading = document.getElementById('loading');
          if (loading) {
            loading.classList.add('loading-hidden');
            setTimeout(function() {
              loading.remove();
            }, 300);
          }
        }, 500);
      });
      
      // 错误处理
      window.addEventListener('error', function(e) {
        console.error('Application error:', e.error);
        const loading = document.getElementById('loading');
        if (loading) {
          loading.innerHTML = `
            <div>
              <div style="color: #ef4444; font-size: 18px; margin-bottom: 8px;">⚠️ 加载失败</div>
              <div style="color: #6b7280; font-size: 14px;">请刷新页面重试</div>
            </div>
          `;
        }
      });
      
      // 未捕获的Promise错误
      window.addEventListener('unhandledrejection', function(e) {
        console.error('Unhandled promise rejection:', e.reason);
      });
    </script>
  </body>
</html>
